package com.kiko.education.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.kiko.education.mapper.ClassInfoMapper;
import com.kiko.education.mapper.ClassMapper;
import com.kiko.education.mapper.CourseScoreMapper;
import com.kiko.education.model.Course;
import com.kiko.education.model.Score;
import com.kiko.education.service.CourseService;
import com.kiko.education.service.ScoreService;
import com.kiko.education.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Controller
public class TeacherController {
    @Autowired
    private UserService userService;
    @Autowired
    private ClassMapper classMapper;
    @Autowired
    private ClassInfoMapper classInfoMapper;
    @Autowired
    private CourseScoreMapper courseScoreMapper;
    @Autowired
    private CourseService courseService;
    @Autowired
    private ScoreService scoreService;

    private final String[] stringList1 = {"周一", "周二", "周三", "周四", "周五", "周六", "周日"};
    private final String[] stringList2 = {"（1，2）","（3，4）","（5，6）","（7，8）","（9，10）","（11，12）"};

    //学生选课跳转
    @RequestMapping(value="/TeaCourseInfo", method = RequestMethod.GET)
    public String toSelectCourse(@RequestParam String userID, Model model){
        System.out.println(userID);
        List<Course> courseList = courseService.getCourseID(userID);
//        List<String> teacherList = new ArrayList<>();
        model.addAttribute("userID", userID);
//        model.addAttribute("teacherList", teacherList);
        model.addAttribute("courseList", courseList);
        return "/teaCourse";
    }

    @RequestMapping(value = "/ClassUpdate",method = RequestMethod.GET)
    public String toUpdate(@RequestParam String userID, Model model){
        List<Course> courseList = courseService.getCourseID(userID);
        model.addAttribute("userID", userID);
        model.addAttribute("courseList", courseList);
        return "/ClassUpdate";
    }

}
